package cn.cnlee.app.base;

import android.content.Intent;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;

import cn.cnlee.app.ui.user.UserLoginActivity;
import cn.cnlee.arch.base.AbsViewModel;
import cn.cnlee.arch.util.Logger;

public class BaseMiddleActivity<T extends AbsViewModel> extends AbsLifecycleActivity {

    @Override
    public void initViews(Bundle savedInstanceState) {
        super.initViews(savedInstanceState);
        mViewModel.mRepository.actionData.observe(this, actionObserver);
    }

    @Override
    public int getLayoutId() {
        return 0;
    }

    /**
     *
     */
    protected Observer actionObserver = new Observer<Integer>() {
        @Override
        public void onChanged(@Nullable Integer action) {
            Logger.e("=======onChanged====== " + action);
            switch (action) {
                case -100:
                    Intent intent = new Intent(BaseMiddleActivity.this, UserLoginActivity.class);
                    startActivity(intent);
                    break;
                default:
                    break;
            }
        }
    };
}
